<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['hdps']=$basic['hdps'];
if($_RQ['op']=='main'){	
	set_html('title','课程列表');
	$return['sharedata']=array(
		'title'=>'课程列表'.$basic['share_title'],
		'desc'=>'课程列表'.$basic['share_desc'],
		'link'=>custom_url('jy_kexie/lesson_list/',true),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	$return['storetype']=0;
	exi($return);
}
if($_RQ['op']=='getlist'){
	$post=get_postdata();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	$storetype=intval($_RQ['storetype']);
	$stores=pdo_getall('jy_kexie_store',array('type'=>$storetype,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	if($stores){
		$storesid=array_keys($stores);
		$params['storeid']=$storesid;
	}else{
		$params['storeid']=0;
	}
	//排序门店
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	
	//$list=pdo_getslice('jy_kexie_store',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['status']=0;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'fields'=>$fields,
		'orderby'=>$orderby,
	);
	$lesson_pai=pdo_getslice('jy_kexie_lesson_pai',$params,array($pindex,$psize),$total,$fields,'','id desc');
	$sum=0;
	$list=array();
	if($lesson_pai){
		$sum=count($lesson_pai);
		foreach($lesson_pai as &$item){		
			$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
			if(!$item['lessonid']){
				continue;
			}
			$onday=$this->model('lesson')->get_onday($item['lessonid']);
			$list[$item['lessonid']]=array(
				'lesson'=>pdo_get('jy_kexie_lesson',array('id'=>$item['lessonid'],'uniacid'=>$_SESSION['uniacid']),array('id','title','description','image')),
				'store'=>pdo_get('jy_kexie_store',array('id'=>$item['storeid'],'uniacid'=>$_SESSION['uniacid']),array('id','title','address')),
				'onday'=>$onday,
			);
		}
	}
	$return['list']=$list;
	$return['sum']=$sum;
	exi($return);
}
	
